<template>
    <view>
        <view class="uni-header">
            <view class="uni-group">
                <view class="uni-title">老人列表</view>
            </view>
            <view class="uni-group">
                <input class="uni-search" type="text" v-model="searchVal" placeholder="请输入搜索id" />
                <button class="uni-button" type="default" size="mini" @click="search">搜索</button>
            </view>
        </view>
        <view class="uni-container">
            <uni-table :loading="loading" sortable border stripe  emptyText="暂无更多数据" @selection-change="selectionChange">
                <uni-tr>
                  <!--  <uni-th width="150" align="center">事件id</uni-th> -->
					<uni-th width="150" align="center">老人id</uni-th>
                    <uni-th width="150" align="center">老人昵称</uni-th>
					<uni-th width="150" align="center">老人电话</uni-th>
					<uni-th width="150" align="center">紧急联系人</uni-th>
					<uni-th width="150" align="center">身份ID</uni-th> 
                    <uni-th  align="center">设置</uni-th>
                </uni-tr>
                <uni-tr v-for="(item ,index) in tableData" :key="index">
                  <uni-td>{{item._id}}</uni-td>
				   <uni-td>
                        <view class="name">{{item.nickname}}</view>
                    </uni-td>
                    <uni-td>{{item.username}}</uni-td>
					<uni-td>{{item.emergencyPhone}}</uni-td>
					<uni-td>{{item.identity}}</uni-td>
                    <uni-td>
                        <view class="uni-group">
                            <button class="uni-button" size="mini" type="primary">查看</button>
							<button class="uni-button" size="mini" type="warn">删除</button>  
                        </view>
                    </uni-td>
                </uni-tr>
            </uni-table>
         <!--   <view class="uni-pagination-box">
                <uni-pagination show-icon :page-size="pageSize" :current="pageCurrent" :total="total" @change="change" />
            </view> -->
        </view>
		<!-- #ifndef H5 -->
		<fix-window />
		<!-- #endif -->
    </view>
</template>

<script>

    export default {
        data() {
            return {
                searchVal: '',
                tableData: [],
                // 每页数据量
                pageSize: 10,
                // 当前页
                pageCurrent: 1,
                // 数据总量
                total: 0,
                loading: false
            }
        },
        onLoad() {
            this.selectedIndexs = []
			this.getData();
        },
        methods: {
            // 搜索
            search() {
                this.getData(1, this.searchVal)
            },
            // 获取老人数据
            getData() {
                this.loading = true  //开启加载
				//获取事件信息
				uniCloud.callFunction({
					name:"getUserInfo",
					data:{
					//	userId:res.result.data[0].oldId,
					type:0  //0为老人 1为志愿者信息查询
					},
					success: (res) => {
						console.log("老人信息");
						console.log(res);
						this.loading = false;	 
						this.tableData = res.result.data;
					}
				});	
            }
        }
    }
</script>

<style>
	/* #ifndef H5 */
	page {
		padding-top: 85px;
	}
	/* #endif */
</style>
